// 画圆
function drawCircle(svg, elementId, strokeColor, fillcolor, cx, cy, r, strokeWidth, dasharray, pathTitle) { 
	drawEclipse(svg, elementId, strokeColor, fillcolor, cx, cy, r, r, strokeWidth, dasharray, pathTitle);
};

// 画椭圆
function drawEclipse(svg, groupName, strokeColor, fillcolor, cx, cy, rx, ry, strokeWidth, dasharray, pathTitle) { 
	svg.append("ellipse")
		.attr("name", groupName)
		.attr("cx",cx)
		.attr("cy",cy)
		.attr("rx",rx)
		.attr("ry",ry)
		.attr("fill",fillcolor)
		.attr("stroke",strokeColor)
		.attr("stroke-width",strokeWidth)
		.attr("stroke-dasharray",dasharray)
		.append("title")
		.html(pathTitle);
};

// 矩形
function drawRect(svg, groupName, strokeColor, rectx, recty, rectWidth, rectHeight, rx, ry, fillColor, strokeWidth, processEvent, pathTitle) {
	svg.append("rect")
		.attr("name", groupName)
		.attr("x",rectx)
		.attr("y",recty)
		.attr("width",rectWidth)
		.attr("height",rectHeight)
		.attr("rx",rx)
		.attr("ry",ry)
		.attr("fill",fillColor)
		.attr("stroke",strokeColor)
		.attr("stroke-width",strokeWidth)
		.each(function (d) {
			if (processEvent.clickEvent != "") {
				d3.select(this)
					.attr("onclick",processEvent.clickEvent)
					.attr("title",processEvent.processInstanceId);
			};
		})
		.append("title").html(pathTitle);;
};

// 画线条
function drawPolyLine(svg, groupName, strokeColor, points, strokeWidth, pathTitle) {
	svg.append("polyline")
		.attr("name", groupName)
		.attr("points", points)
		.attr("stroke", strokeColor)
		.attr("fill", "white")
		.attr("stroke-width",strokeWidth)
		.append("title").html(pathTitle);
};

// 画线段
function drawLine(svg, groupName, strokeColor, x1, y1, x2, y2, hasArrow) {
	var line = svg.append("line")
					.attr("name", groupName)
					.attr("stroke",strokeColor)
					.attr("x1", x1)
					.attr("y1", y1)
					.attr("x2", x2)
					.attr("y2", y2)
					.each(function (d) {
						if (hasArrow) {
							if (strokeColor == passedColor) {
								d3.select(this)
									.attr("marker-end","url(#markerEndArrowPassed)");
							} else {
								d3.select(this)
									.attr("marker-end","url(#markerEndArrow)");
							};
							
						};
					});
};

// 路径
function drawPath(svg, groupName, strokeColor, fillcolor, strokeWidth, path) {
	svg.append("path")
		.attr("name", groupName)
		.attr("d", path)
		.attr("fill", "white")
		.attr("stroke", strokeColor)
		.attr("stroke-width", strokeWidth);
};


function drawPolygon(svg, groupName, strokeColor, fillcolor, opacity, points) {
	svg.append("polygon")
		.attr("name", groupName)
		.attr("fill", fillcolor)
		.attr("stroke",strokeColor)
        .attr("opacity",opacity)
        .attr("points",points);
};

// 文字
function drawFont(svg, groupName, strokeColor, x, y, elementName, fontSize, fontWeight, wrap, pathTitle) {
	// <text font-size="12" id="text_name" x="34" y="66" oryx:align="center top" stroke="black" />
	svg.append("text")
		.attr("name", groupName)
		.attr("font-size", fontSize)
		.attr("font-weight", fontWeight)
		.attr("x", x)
		.attr("y", y)
		.attr("text-anchor", "middle")
		// .html(elementName);
    	.each(function (d) {
	        var lines = wordwrap(elementName, wrap);
	        for (var i = 0; i < lines.length; i++) {
	            d3.select(this)
	            	.append("tspan")
	            	.attr("dy",13)
	            	.attr("x",x)
					.attr("fill", strokeColor)
	            	.text(lines[i]);
	        }
	    })
	    .append("title").html(pathTitle);
};


